package main.java.service.impl;

import main.java.dao.UserDao;
import main.java.dao.impl.UserDaoImpl;
import main.java.domain.User;
import main.java.service.UserService;

import java.util.List;


public class UserServiceImpl implements UserService {
    private UserDao dao = new UserDaoImpl();

    @Override
    public User login(User user) {
        User queryUser = dao.findUserByStudent(user.getUsername(), user.getPassword());
        if(queryUser == null)
            return dao.findUserByTeacher(user.getUsername(), user.getPassword());
        return queryUser;
    }

    @Override
    public User findTeacherOfTaskID(int id) {
        return dao.findTeacherOfTaskID(id);
    }

    @Override
    public List<User> findAll() {
        return dao.findAll();
    }
}
